﻿<phone:PhoneApplicationPage 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
	x:Class="WeiboSdkSample.SampleTimeline"
	FontFamily="{StaticResource PhoneFontFamilyNormal}"
	FontSize="{StaticResource PhoneFontSizeNormal}"
	Foreground="{StaticResource PhoneForegroundBrush}"
	Orientation="Portrait"
	shell:SystemTray.IsVisible="True"
    Loaded="PhoneApplicationPage_Loaded"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">
    
	<phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="StatusTemplateComplex">
            <Grid Margin="0,12,8,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel x:Name="LeftPanel" Orientation="Vertical" d:LayoutOverrides="Height" Margin="0,0,8,0">
                    <Border x:Name="ProfileBorder" BorderThickness="2" Width="64" Height="64" HorizontalAlignment="Left" VerticalAlignment="Top">
                        <Border.BorderBrush>
                            <SolidColorBrush Color="{StaticResource PhoneBorderColor}"/>
                        </Border.BorderBrush>
                        <Canvas Margin="0">
                            <Image x:Name="ProfileImage" Source="{Binding User.ProfileImage}" Height="56" Width="56" Canvas.Left="2" Canvas.Top="2"/>
                            <Image x:Name="VerifyLogo" Height="26" Width="26" Canvas.Left="40" Canvas.Top="40" Source="/Resources/Images/SinaResource.Verifier.png" Visibility="{Binding User.IsVerified}" Stretch="UniformToFill"/>
                        </Canvas>
                    </Border>
                </StackPanel>

                <StackPanel x:Name="RightPanel" Grid.Column="1" Grid.Row="0" Margin="0" Orientation="Vertical" d:LayoutOverrides="Height" >
                    <Grid x:Name="HeaderGrid" Margin="0,0,0,10">
                        <Grid.Background>
                            <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                        </Grid.Background>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Button x:Name="UserButton" Height="50" Margin="-10" HorizontalContentAlignment="Left" FontSize="20" BorderThickness="0" Content="{Binding User.Name}" Padding="10,0"/>
                        <Image x:Name="StatusPicHint" Grid.Column="2" Source="/Resources/Images/SinaResource.Statuspic.png" Visibility="{Binding IsThumbnail}" Margin="0,0,12,0"/>
                    </Grid>
                    <TextBlock x:Name="StatusBlock" Text="{Binding Message}" TextWrapping="Wrap" FontSize="21.333" />
                    <Image x:Name="ThumbImage" Source="{Binding ThumbnailPic}" HorizontalAlignment="Left" Stretch="Uniform" Height="120" Width="120" Visibility="{Binding IsThumbnail}" Margin="0,12,0,0" VerticalAlignment="Top"/>
                    <Border x:Name="RetweetBorder" Margin="0,12,0,0" Padding="8,12" Visibility="{Binding IsRetweetedStatus}" CornerRadius="10">
                        <Border.Background>
                            <SolidColorBrush Color="{StaticResource PhoneChromeColor}"/>
                        </Border.Background>
                        <StackPanel>
                            <TextBlock x:Name="RetweetUserBlock" TextWrapping="Wrap" Text="{Binding RetweetedStatus.User.Name}" Margin="0,0,0,10" FontWeight="Bold">
    							<TextBlock.Foreground>
    								<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
    							</TextBlock.Foreground>
                            </TextBlock>
                            <TextBlock x:Name="RetweetStatusBlock" TextWrapping="Wrap" Text="{Binding RetweetedStatus.Message}">
    							<TextBlock.Foreground>
    								<SolidColorBrush Color="{StaticResource PhoneContrastBackgroundColor}"/>
    							</TextBlock.Foreground>
                            </TextBlock>
                            <Image x:Name="RetweetThumbImage" 
                                   Margin="0,12,0,0" 
                                   Stretch="Uniform" 
                                   Source="{Binding RetweetedStatus.ThumbnailPic}" 
                                   Visibility="{Binding IsThumbnail}" 
                                   HorizontalAlignment="Left" 
                                   VerticalAlignment="Top" 
                                   Height="120" Width="120"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <Grid x:Name="FooterGrid" Margin="0,12,0,0" Grid.Row="1" Grid.Column="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <StackPanel x:Name="SourcePanel" Orientation="Horizontal" HorizontalAlignment="Left" d:LayoutOverrides="HorizontalAlignment, GridBox">
                        <TextBlock 
    						Text="由" 
    						HorizontalAlignment="Left" 
    						VerticalAlignment="Bottom"
    						FontSize="18.667" >
    						<TextBlock.Foreground>
    							<SolidColorBrush Color="{StaticResource PhoneForegroundColor}"/>
    						</TextBlock.Foreground>
                        </TextBlock>
                        <TextBlock x:Name="SourceBlock"
    						Text="{Binding Source}" 
    						d:LayoutOverrides="Width" 
    						HorizontalAlignment="Left" 
    						VerticalAlignment="Bottom" 
    						FontSize="18.667">                       
    						<TextBlock.Foreground>
    							<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
    						</TextBlock.Foreground>
                        </TextBlock>
                        <TextBlock
    						Text="发布" 
    						d:LayoutOverrides="Width" 
    						HorizontalAlignment="Left" 
    						VerticalAlignment="Bottom" 
    						FontSize="18.667">
    						<TextBlock.Foreground>
    							<SolidColorBrush Color="{StaticResource PhoneForegroundColor}"/>
    						</TextBlock.Foreground>
                        </TextBlock>
                    </StackPanel>
                    <TextBlock x:Name="CreateTimeBlock" Text="{Binding CreateTime}" FontSize="20" VerticalAlignment="Bottom" Grid.Column="1" HorizontalAlignment="Right">
    					<TextBlock.Foreground>
    						<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
    					</TextBlock.Foreground>
                    </TextBlock>
                </Grid>

                <Path x:Name="Separater" Data="M0,80 L448,80" Height="1" Margin="0" Grid.Row="2" Grid.ColumnSpan="2" Stretch="Fill" UseLayoutRounding="False" VerticalAlignment="Top" HorizontalAlignment="Center">
                    <Path.Stroke>
                        <SolidColorBrush Color="{StaticResource PhoneForegroundColor}"/>
                    </Path.Stroke>
                </Path>
            </Grid>
        </DataTemplate>        
	</phone:PhoneApplicationPage.Resources>

	<!--LayoutRoot is the root grid where all page content is placed-->
	<Grid x:Name="LayoutRoot" Background="Transparent">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
		
		<!--TitlePanel contains the name of the application and page title-->
		<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
			<TextBlock x:Name="ApplicationTitle" Text="WEIBO SDK" Style="{StaticResource PhoneTextNormalStyle}"/>
			<TextBlock x:Name="PageTitle" Text="SampleHome" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
		</StackPanel>

		<!--ContentPanel - place additional content here-->
		<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox x:Name="friendsTimeline"
                     ItemsSource="{Binding FriendTimelineList}" 
                     ItemTemplate="{StaticResource StatusTemplateComplex}"/>
        </Grid>
	</Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="refreshIconButton" IconUri="Resources/Icons/appbar.refresh.rest.png" Text="刷新" Click="refreshIconButton_Click"/>
            <shell:ApplicationBarIconButton x:Name="sendIconButton" IconUri="Resources/Icons/appbar.edit.rest.png" Text="发送微博" Click="sendIconButton_Click"/>
            <shell:ApplicationBarIconButton x:Name="shareIconButton" IsEnabled="False" IconUri="Resources/Icons/appbar.share.rest.png" Text="一键分享" Click="shareIconButton_Click"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>